from django.template import Template, Context
from django.shortcuts import render_to_response
from django.http import HttpResponse
import datetime
#from bandtogether.forms import LocationForm, SearchForm
from request import *

def main(request):
        current_date = datetime.datetime.now()

	if request.method == 'POST':

		my_location = request.POST.get('locField')
		   	
		return render_to_response('index.html', locals())

	return render_to_response('index.html', locals())
	
def findVenue(request):

	if request.method == 'POST':

		venueQuery = request.POST.get('venue')

		venueResults = getVenueName(venueQuery)
		   	
		return render_to_response('findVenue.html', locals())

	return render_to_response('findVenue.html', locals())

def findArtist(request):

	if request.method == 'POST':

		artistQuery = request.POST.get('artist')
		
		artistResults = getPerformerIDs(artistQuery)
		   	
		return render_to_response('findArtist.html', locals())

	return render_to_response('findArtist.html', locals())

def findGenre(request):

	if request.method == 'POST':

		genreQuery = request.POST.get('genre')
		#location = my_location.replace(" ", "+")
		
		genreResults = getVenueName(genreQuery)
		   	
		return render_to_response('findGenre.html', locals())

	return render_to_response('findGenre.html', locals())
	
def venuePage(request, venue):

	venue_pics = [ 'pub1.jpg', 'pub2.jpg' , 'pub3.jpg', 'pub4.jpg' ]
	popularBands = [ ('Blaggards','blaggards.jpg') ]
	popularGenres = [ ('Celtic Rock', 'celticRock.jpeg') ]
	ids = getVenueIDs(venue,'')	
	#test = getVenueDescription(venue)

	return render_to_response('myVenue.html', locals())
	
def artistPage(request, artist):

	artistPic = 'sJam.jpg'
	artistGenres = [ 'Funk', 'Jam Band', 'Rock' ]

	return render_to_response('myArtist.html', locals())
	
def genrePage(request, genre):

	#popularGenres = [ ('Celtic Rock', 'celticRock.jpeg') ]
	genreBands = [ ('Blaggards','blaggards.jpg') ]

	return render_to_response('myGenre.html', locals())

def artist(request):

	#my_location = ""

	return render_to_response('artist.html', locals())

def venue(request):
	
	#events = getVenueName(location)

	return render_to_response('venue.html', locals())
	
def about(request):
	return render_to_response('about.html', locals())

def team(request):
	return render_to_response('team.html', locals())
	
def api(request):
	return render_to_response('api.html', locals())
	
def faq(request):
	return render_to_response('faq.html', locals())
	
def terms(request):
	return render_to_response('terms.html', locals())	

def what(request):
	return render_to_response('what.html', locals())

def static(request):
        code = urlparse(request.path)
        parts = code.geturl().split('/')
        url = parts.pop(len(parts)-1) + '.html'
        return render_to_response(url)


